<template>
  <div class="main">
    <div class="content">
      <div class="content_form">
        <el-form ref="form" :model="form" label-width="140px" class="form_item" :rules="rules">
          <el-row :gutter="24">
            <el-col :span="13">
              <el-form-item label="公告标题" prop="title">
                <el-input v-model="form.title"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公告内容" prop="notices">
                <el-input v-model="form.notices" type="textarea"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="是否显示" prop="isShow">
              <el-radio v-model="form.isShow" :label="0">显示</el-radio>
              <el-radio v-model="form.isShow" :label="1" >隐藏</el-radio>
              </el-form-item>
            </el-col>
			
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import { getToken, setToken, removeToken } from '@/utils/auth';
import { updateNotice,roleDeptTreeselect1s,getNoticeId} from '@/api/user';
export default {
    components: {},
    data() {
        return {
            engineering: '',
            engineeringTypeOption: [],
            form: {
                title: '',
                isShow: '',
                notices: '',
                id:'',
			
            },
            data:[],
            id:'',
            rules: {
                title: [{ required: true, message: '请填写内容', trigger: 'blur' }]
            }
        };
    },
    created() {
        roleDeptTreeselect1s()
            .then(response => {
                if (response.data.code == 200) {
                    this.data = response.data.depts;
                    consolwe.log(response.data)
                } else {
                }
            })
            .catch(() => {
            });
            console.log(this.form)
        //  getNoticeId().then(response => {
        //     console.log('44444'+response)
        //   }) 
    },
    methods: {
       handleNodeClick(id) {
			    console.log("我是那个点击的数",id.id);
          var deptId=id.id
          this.id = deptId
					this.roleDeptTreeselect1s(deptId)
            },
          roleDeptTreeselect1s(deptId){
					   var params_list={
						   deptId:deptId
             }
             console.log('33333'+deptId)
           },
        // 保存
        editSave() {
            var params_one = {
                id:this.form.id,
                title: this.form.title,
                isShow: this.form.isShow,
                notices: this.form.notices
            };
            console.log(params_one)
            updateNotice(params_one)
                .then(response => {
					
					 if(response.data.code == 200){
					 		this.$message({
					 			  message: '修改成功',
					 			  type: 'success'
					 		 });
					 }else{
					 	this.$message.error(response.data.msg);
					 }
                    this.$emit('closeModal', false);
                })
                .catch(() => {
                    // this.loading = false
                    // this.$message.error(response.data.msg)
                });
        },
		/*********修改接口***********/
		modify_display_notice(){
			
			console.log("我是修改的回显")
			 console.log("我是111222",this.EngineeringData[0])
			var roleId={
				id:this.EngineeringData[0].id
			}
			getNoticeId(roleId).then((response) => {
				console.log("我是修改需要的回显")
				if(response.data.code == 200){
						console.log("我是修改的回显数据",response)
						this.form=response.data.data
						
				}else{
					this.$message.error(response.data.msg);
				}
			}).catch(() => {
				// console.log("我是点击了取消")
			})
		}
		/*********修改接口*************/
    },
  props: ["EngineeringData"],
  mounted: function() {
    //异步加载
    // this.form = this.EngineeringData[0];
  },
  watch: {
    EngineeringData() {
      //数据监视
      this.form = this.EngineeringData[0];
    }
  }
};
</script>
<style scoped>
</style>